package com.abc.mapper;


import com.abc.bean.Bunk;
import com.abc.bean.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:34
 * @Description:
 */
public interface DepartmentMapper {
    @Select("<script>" +
        "select id,department_name as departmentName,department_address as departmentAddress,department_tel as departmentTel from department" +
        "<where>" +
        "<if test='departmentName!=null and departmentName!=\"\"'>" +
        "and department_name like concat('%',#{departmentName},'%')" +
        "</if>" +
        "</where>"+
        "</script>")
    List<Department> selectDepartment(@Param("departmentName") String departmentName);

    @Select(" select id,department_name as departmentName from department")
    List<Department> selectAllDepartment();

    @Insert("insert into department(department_name,department_address,department_tel) values (#{departmentName},#{departmentTel},#{departmentAddress}) ")
    int addDepartment(Department department);

    @Delete("delete from department where id=#{id}")
    int deleteDepartment(String id);

    @Select("select id,department_name as departmentName,department_address as departmentAddress,department_tel as departmentTel from department where id=#{id}")
    Department selectOneDepartmentById(String id);

    @Update("update department set department_address=#{departmentAddress},department_tel=#{departmentTel} where id=#{id}")
    int updateDepartmentById(Department department);
}
